using UnityEditor;
using UnityEngine;
using System;
using System.Collections;

public class FactoryTool
{
	[MenuItem("Tools/ObjectFacotryConfig File AutoSync")]
	public static void AutoSync()
	{
		Hashtable ht = new Hashtable();
		foreach(FactoryType type in Enum.GetValues(typeof(FactoryType)))
		{
			if(type.ToString() == "Character")
			{
				ArrayList array_character = new ArrayList();
				foreach(CharacterType c in Enum.GetValues(typeof(CharacterType)))
				{
					array_character.Add(c.ToString());
				}
				ht.Add(type.ToString(),array_character);
			}

			if(type.ToString() == "BounusItem")
			{

				ArrayList array_bounus = new ArrayList();
				foreach(BounusItemType c in Enum.GetValues(typeof(BounusItemType)))
				{
					array_bounus.Add(c.ToString());
            	}
				ht.Add(type.ToString(),array_bounus);
            }

			if(type.ToString() == "Equipment")
			{
				ArrayList array_equipment = new ArrayList();
				foreach(EquipmentType c in Enum.GetValues(typeof(EquipmentType)))
				{
					array_equipment.Add(c.ToString());
				}
				ht.Add(type.ToString(),array_equipment);
            }

			if(type.ToString() == "Hud")
			{
				ArrayList array_hud = new ArrayList();
				foreach(HudType c in Enum.GetValues(typeof(HudType)))
				{
					array_hud.Add(c.ToString());
				}
				ht.Add(type.ToString(),array_hud);
			}

			if(type.ToString() == "ParticleEffect")
			{
				ArrayList array_particle = new ArrayList();
				foreach(ParticleEffectType c in Enum.GetValues(typeof(ParticleEffectType)))
				{
					array_particle.Add(c.ToString());
                }
				ht.Add(type.ToString(),array_particle);
            }
		}

		string result = MiniJSON.JsonEncode(ht);
		string factoryPath = ObjectFactory.AssetPath + "/" + ObjectFactory.CONFIG_FILE;
		System.IO.File.WriteAllText(factoryPath,result);
        Debug.Log("FactoryTool AutoSync successfully!");
	}

}